<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>订单路线管理</title>
<!-- 引入easyui 的主题样式  和  easyui 提供的图标样式 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/icon.css" />
<!-- 引入jquery 和  easyui.js   中文设置js-->
<script type="text/javascript"
	src="${pageContext.request.contextPath}\js\jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
$(function(){
$('#dg').datagrid({    
    url:'getOrderByState',    
    columns:[[
        {field : 'ck',width : 100,checkbox : true},       
        {field:'orId',title:'订单编号',width:100,align:'center'},    
        {field:'dpNamef',title:'发货地',width:100,align:'center'},    
        {field:'dpNames',title:'目的地',width:100,align:'center'},    
        {field:'orState',title:'订单状态',width:100,align:'center'},   
        {field:'loStart',title:'起点',width:100,align:'center'},   
        {field:'loTransferStation1',title:'中转站1',width:100,align:'center'},       
        {field:'loTransferStation2',title:'中转站2',width:100,align:'center'},       
        {field:'loStop',title:'终点',width:100,align:'center'},       
    ]]  ,
rownumbers : true,
pagePosition : 'bottom',
pagination : true,
pageSize : 10,
pageList : [ 5, 10, 15 ],
toolbar: [{
	iconCls: 'icon-edit',
	text:"调节路线",
	handler: function(){
		var ol = $("#dg").datagrid("getChecked");
		if (ol.length==1) {
		$('#updateorderline').window("open");
			$('#orId').textbox({    
		    	value: ol[0].orId,     
			})
			$('#loStart').textbox({    
			    value: ol[0].dpNamef,     
			})
			$('#loStop').textbox({    
			    value: ol[0].dpNames,     
			})
		}else{
			$.messager.alert('警告','请选择需要调节路线的订单！');  
		}
	}
}]
});


//修改窗口
$('#updateorderline').window({
	width : 400,
	height : 450,
	modal : true,
	title : "调节路线",
	collapsible : false,
	minimizable : false,
	maximizable : false,
	closable : false,
	closed : true
});

$('#orId').textbox({
	buttonText : '订单编号',
	buttonAlign:"left",
	readonly:true
});

$('#loStart').textbox({
	buttonText : '起点',
	buttonAlign:"left",
	readonly:true
});
$('#loTransferStation1').combobox({  
	
    url:'findTranSta1',    
    valueField:'lineStartPoint',    
    textField:'lineStartPoint',
    buttonText : '中转站1',
    buttonAlign:"left",
    editable:false,
    onShowPanel:function(){
    	var lineEndPoint   =  $('#loStart').val();
    	
    	var url = "findTranSta1?lineEndPoint="+encodeURIComponent(encodeURIComponent(lineEndPoint));
    	$('#loTransferStation1').combobox('reload',url);
    },
    onSelect: function(record){  
    	
    	var url = "findTranSta2?lineStartPoint="+encodeURIComponent(encodeURIComponent(record.lineStartPoint));
    	$('#loTransferStation2').combobox('clear');
    	$('#loTransferStation2').combobox('reload',url);
	 
    }

})
$('#loTransferStation2').combobox({    
    url:'findTranSta2',    
    valueField:'lineEndPoint',    
    textField:'lineEndPoint',
    buttonText : '中转站2',
    buttonAlign:"left",
    editable:false,
 onSelect: function(record){  
    	
    	var url = "findTranSta2?lineStartPoint="+encodeURIComponent(encodeURIComponent(record.lineStartPoint));
    	$('#lineTransportationType').combobox('clear');
    	$('#lineTransportationType').combobox('reload',url);
	 
    }
    });
$('#loStop').textbox({
	buttonText : '终点',
	buttonAlign:"left",
	readonly:true
});
    
//增加确定按钮
$('#insertyes').linkbutton({
	onClick : function() {
		$('#updateorderline').window("close");
		$.ajax({
			url : 'insertOrderLine',
			type : 'post',
			data : {
				'orId':$("#orId").val(),
				'loStart' : $("#loStart").val(),
				'loStop' : $("#loStop").val(),
				'loTransferStation1' : $('#loTransferStation1').combobox('getValue'),
				'loTransferStation2' : $('#loTransferStation2').combobox('getValue'),
			},
			dataType : 'text',
			success : function(data) {
				alert(data)
				if (data == 1) {
					$("#dg").datagrid('reload');
					$.messager.alert('消息','路线调节成功');  
				} else {
					$.messager.show({
						title : '信息提示',
						msg : '修改失败',
						timeout : 1000,
						showType : 'slide'
					});
				}

			}
		});
	}
});
//修改取消
$('#insertno').linkbutton({
	onClick : function() {
		$('#updateorderline').window("close");
		$("#dg").datagrid('uncheckAll')
	}
});


});
</script>
<body>
<table id="dg"></table>

<!-- 修改窗口 -->

	<div id="updateorderline">
		
<div style="margin-left: 100px; margin-top: 50px">
			<input id="orId" type="text" 
				style="width: 200px; height: 32px"><br><br>
			<input id="loStart" type="text" 
				style="width: 200px; height: 32px"><br><br>
			 <input
				id="loTransferStation1" type="text" 
				style="width: 200px; height: 32px"> <br><br>
				 <input
				id="loTransferStation2" type="text" 
				style="width: 200px; height: 32px"> <br><br>
				 <input id="loStop" type="text" 
				style="width: 200px; height: 32px"><br><br>
				
				 
				<br><br>
				 <a id="insertyes" href="#" iconCls="icon-ok"
				style="width: 90px; height: 32px;">确定</a>
				 <a id="insertno" href="#"
				iconCls="icon-no" style="width: 90px; height: 32px">取消</a>

		</div>
		</div>
		
		
</body>
</html>